<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>AdWords::AdWordsLogger</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
    <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>     
    <div class="banner">
        <h1>
            <span class="type">Class</span> 
            AdWords::AdWordsLogger 
            
                <span class="parent">&lt; 
                    
                    Object
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/lib/adwords4r/adwordslogger_rb.html">lib/adwords4r/adwordslogger.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    
    <div class="description">
        <p>
Wrapper class to handle logging to console and/or files.
</p>

    </div>
    

    

    
    

    
    
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
    
        <dt>#</dt>
        <dd>
            <ul>
                
                <li><a href="#M000004"><<</a></li>
                
            </ul>
        </dd>
    
        <dt>L</dt>
        <dd>
            <ul>
                
                <li><a href="#M000002">log_to_file</a></li>
                
            </ul>
        </dd>
    
        <dt>N</dt>
        <dd>
            <ul>
                
                <li><a href="#M000001">new</a></li>
                
            </ul>
        </dd>
    
    </dl>
    

    

    

    

    

    

    
            <div class="sectiontitle">Class Public methods</div>
            
            <div class="method">
                <div class="title" id="M000001">
                    
                    <a name="M000001"></a><b>new</b>(filename, log_to_console=false)
                    
                </div>
                
                <div class="description">
                  <p>
Constructor for <a href="AdWordsLogger.html">AdWordsLogger</a>.
</p>
<p>
Args:
</p>
<ul>
<li>filename: the filename for the log file to be written (if <a
href="AdWordsLogger.html#M000002">log_to_file</a> is called)

</li>
<li>log_to_console: boolean, indicates whether or not to log to the console

</li>
</ul>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show</a>
                        
                    </p>
                    <div id="M000001_source" class="dyn-source">
                        <pre><span class="ruby-comment cmt"># File lib/adwords4r/adwordslogger.rb, line 36</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">log_to_console</span>=<span class="ruby-keyword kw">false</span>)
      <span class="ruby-ivar">@filename</span> = <span class="ruby-identifier">filename</span>
      <span class="ruby-ivar">@loggers</span> = []
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">log_to_console</span>
        <span class="ruby-identifier">stderr_logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">STDERR</span>)
        <span class="ruby-identifier">stderr_logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>
        <span class="ruby-ivar">@loggers</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">stderr_logger</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="sectiontitle">Instance Public methods</div>
            
            <div class="method">
                <div class="title" id="M000004">
                    
                    <a name="M000004"></a><b>&lt;&lt;</b>(text)
                    
                </div>
                
                <div class="description">
                  <p>
Overload << operator to perform logging.
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show</a>
                        
                    </p>
                    <div id="M000004_source" class="dyn-source">
                        <pre><span class="ruby-comment cmt"># File lib/adwords4r/adwordslogger.rb, line 62</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">text</span>)
      <span class="ruby-ivar">@loggers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">logger</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">to_s</span>
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="M000002">
                    
                    <a name="M000002"></a><b>log_to_file</b>(path='.')
                    
                </div>
                
                <div class="description">
                  <p>
Enables logging to a file. May be called several times to log to multiple
files.
</p>
<p>
Args:
</p>
<ul>
<li>path: where to write the file (defaults to current dir). Path only, do not
provide filename.

</li>
</ul>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show</a>
                        
                    </p>
                    <div id="M000002_source" class="dyn-source">
                        <pre><span class="ruby-comment cmt"># File lib/adwords4r/adwordslogger.rb, line 53</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log_to_file</span>(<span class="ruby-identifier">path</span>=<span class="ruby-value str">'.'</span>)
      <span class="ruby-identifier">new_logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-ivar">@filename</span>))
      <span class="ruby-identifier">new_logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>
      <span class="ruby-ivar">@loggers</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">new_logger</span>

      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
    <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
</div>
    </div>
  </body>
</html>    